#include "Config.h"
#include "GPIO.h"
#include "UART.h"
#include "NVIC.h"
#include "Switch.h"
#include "delay.h"
#include "STC8H_PWM.h"
#include "Timer.h"

#include "usb.h"
#include "usb_req_class.h"

#include "LightStrip_Run_1.h"
#include "LightStrip_Run_2.h"
#include "LightStrip_Run_3.h"
#include "LightStrip_Run_4.h"
#include "KeyBoard.h"
#include "KB_LightStrip.h"
#define TASK_LS_1 2
#define TASK_LS_2 3
#define TASK_LS_3 4
#define TASK_LS_4 5
#define TASK_KEYBOARD  6	
#define TASK_LS_KB   7
void sys_init() {
  EAXSFR();
	
	usb_init();
  // key_init();
  LightStrip_init_1();
  LightStrip_init_2();
  LightStrip_init_3();
  LightStrip_init_4();
  KeyBoard_init();
  WS_init_KB(19);
  EA=1;

}


void task_LS_1() _task_ TASK_LS_1{
	LightStrip_Run_1();
}
void task_LS_2() _task_ TASK_LS_2{
	LightStrip_Run_2();
}
void task_LS_3() _task_ TASK_LS_3{
	LightStrip_Run_3();
}
void task_LS_4() _task_ TASK_LS_4{
	LightStrip_Run_4();
}
void task_keyboard() _task_ TASK_KEYBOARD{
	while(1){
		scan_and_send();
		os_wait2(K_TMO, 2);
	}
}
void task_LS_KB() _task_ TASK_LS_KB{
	KB_LightStrip();
}


void task_main() _task_ 0{
  sys_init();
//  os_create_task(TASK_KEY);
    os_create_task(TASK_LS_1);
    os_create_task(TASK_LS_2);
		os_create_task(TASK_LS_3);
		os_create_task(TASK_LS_4);
		os_create_task(TASK_KEYBOARD);
		os_create_task(TASK_LS_KB);
    os_delete_task(0);
}





